Skip to content

feat: enable project-registry affiliation writes (CM-361) - #4302

Merged
skwowet merged 5 commits into
mainfrom
feat/CM-361-part-2
Jul 6, 2026
Merged

feat: enable project-registry affiliation writes (CM-361)#4302
skwowet merged 5 commits into
mainfrom
feat/CM-361-part-2

Conversation

@skwowet

@skwowet skwowet commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Part 2 of CM-361. Part 1 (#4280) discovers and parses project-maintained affiliation files in git_integration but left MO/MSA writes disabled for validation. This PR turns on those writes, adds guards so user actions and enrichment are respected, and collapses overlapping inferential work experiences in the API/UI.

Changes

1. Enable project-registry affiliation writes

  • git_integration: call insert_member_organizations and insert_member_segment_affiliations after lookup/guard checks so parsed repo affiliations land in CDP
  • types: add OrganizationSource.PROJECT_REGISTRY (project-registry)
  • common: rank project-registry above email-domain and enrichment in getMemberOrganizationSourceRank (UI still wins)
  • data-access-layer: include fully undated MSAs in findMemberManualAffiliation and order by dateStart DESC NULLS LAST so new activities resolve repo-derived affiliations the same way bulk refresh already does

2. Guards — prevent unwanted re-apply and enrichment overwrite

git_integration (respect soft-deletes)

  • MO/MSA lookups return soft-deleted rows (deletedAt included; no deletedAt IS NULL filter on fetch)
  • Apply logic splits active vs deleted rows
  • is_blocked_by_deleted_row() skips re-insert when a user soft-deleted a matching stint (same org + overlapping or undated/open-ended dates)
  • Effect: if someone removes a repo-derived affiliation in the UI, the next sync will not resurrect it from the file

members_enrichment_worker (protect project-registry MO rows)

  • prepareWorkExperiences no longer deletes MO rows with source ui or project-registry
  • Effect: enrichment refresh will not wipe project-registry affiliations that are not continuously re-derived like email-domain rows

3. Collapsible work experiences (email-domain + project-registry)

  • Extend the existing email-domain collapse logic in mapper.ts to also treat project-registry as collapsible
  • Overlapping rows for the same organization and date range are grouped into one displayed work experience; sources are merged as a comma-separated string and the date range is unioned
  • Only email-domain and project-registry rows are collapsible; UI and enrichment rows are never hidden, but overlapping collapsible rows tuck under them
  • Source rank for display: UI > project-registry > email-domain > enrichment
  • Public work-experience APIs and internal CDP UI services use the grouped rows for list/delete/update/verify

Generic examples

Stored rows (same org, overlapping dates) What the user sees
project-registry + email-domain One row; project-registry is the display row, sources merged
enrichment + project-registry + email-domain One row under the enrichment entry; inferential sources collapsed beneath it
ui + project-registry One row under the UI entry; project-registry collapsed into it, sources merged

@skwowet skwowet self-assigned this Jul 3, 2026
Copilot AI review requested due to automatic review settings July 3, 2026 11:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is Part 2 of CM-361. Part 1 discovered and parsed project-maintained affiliation files in git_integration but kept the CDP writes disabled for validation. This PR turns those writes on and updates the shared affiliation logic so project-registry member-organization / member-segment-affiliation rows behave correctly downstream — ranked above email-domain/enrichment (but below UI) and picked up during activity ingest.

Changes:

  • git_integration: activate the previously commented-out insert_member_organizations / insert_member_segment_affiliations calls (plus their imports) so parsed repo affiliations land in CDP.
  • Introduce OrganizationSource.PROJECT_REGISTRY and slot project-registry between ui and email-domain in getMemberOrganizationSourceRank.
  • Expand findMemberManualAffiliation to also match fully undated MSAs so new activities resolve repo-derived affiliations like the bulk refresh path already does.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
services/apps/git_integration/src/crowdgit/services/affiliation/affiliation_service.py Enables the actual MO/MSA inserts after lookup/guard checks and imports the two crud helpers.
services/libs/types/src/enums/organizations.ts Adds the PROJECT_REGISTRY = 'project-registry' enum value.
services/libs/common/src/member.ts Re-ranks sources so project-registry outranks email-domain/enrichment but not UI.
services/libs/data-access-layer/src/members/segments.ts Adds a fully-undated branch to the manual-affiliation lookup used during activity ingest.

One concern worth addressing before merge: the new undated branch in findMemberManualAffiliation interacts with ORDER BY "dateStart" DESC (PostgreSQL NULLS FIRST default), which lets an undated catch-all MSA win over a more specific dated MSA that covers the timestamp — see the inline comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread services/libs/data-access-layer/src/members/segments.ts Outdated
Copilot AI review requested due to automatic review settings July 4, 2026 17:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Base automatically changed from feat/CM-361-part-1 to main July 6, 2026 07:45
skwowet and others added 3 commits July 6, 2026 14:24
Turn on MO/MSA writes in git_integration after lookup/guard checks.
Add OrganizationSource.PROJECT_REGISTRY and rank it above email-domain
and enrichment. Fix findMemberManualAffiliation to match fully undated
MSAs with correct ORDER BY for activity ingest resolution.

Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
@skwowet
skwowet force-pushed the feat/CM-361-part-2 branch from 2d68b42 to 6273aaf Compare July 6, 2026 08:55
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 6, 2026 08:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Comment thread backend/src/utils/mapper.ts
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
@skwowet
skwowet merged commit 827c956 into main Jul 6, 2026
11 checks passed
@skwowet
skwowet deleted the feat/CM-361-part-2 branch July 6, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants